package codeRandomThoughts.Test1684统计一致字符串的数目;

public class Solution {
    public int countConsistentStrings(String allowed, String[] words) {
        boolean[] hashMap = new boolean[26];
        for (int i = 0; i < allowed.length(); i++) {
            char c = allowed.charAt(i);
            hashMap[c - 'a'] = true;
        }
        int count = 0;
        for (String word : words) {
            if (isConsistent(word, hashMap)) count++;
        }

        return count;
    }

    public boolean isConsistent(String str, boolean[] hashMap) {
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (!hashMap[c - 'a']) {
                return false;
            }
        }
        return true;
    }
}
